﻿@model List<SelfMadeMillionaire.Web.Infrastructure.ViewModels.Account.CompanyInfo>

<div class="table-responsive">
	@if (Model.Any())
    {        
		<table class="table table-bordered tablesorter">
			<thead>
				<tr>
                    <th><a href="#">Symbol</a></th>

					<th><a href="#">Price</a></th>
					<th><a href="#">Next Earnings Date</a></th>

                    <th><a href="#">Day's Range</a></th>
					<th><a href="#">52wk Range</a></th>
                    <th><a href="#">Avg Vol (3m)</a></th>
					<th><a href="#">Market Cap</a></th>
                    <th><a href="#">P/E (ttm)</a></th>
                    <th></th>
				</tr>
			</thead>
			<tbody>
				@foreach (var item in Model)
    {
					<tr>
                        <td><a href="@item.Url">@item.Symbol</a></td>

						<td>@item.Price</td>
                        <td>@item.NextEarningsDate</td>

                        <td>@item.DaysRange</td>
                        <td>@item.Wk52Range</td>
                        <td>@item.AvgVol3m</td>
                        <td>@item.MarketCap</td>
                        <td>@item.PE</td>
                        
                        <td align="center">
                            <a href="#" class="remove_symbol_lnk" data-id="@item.PortfolioId" data-text="@item.Symbol"><img src="@Url.Content("~/Content/Images/delete.png")" alt="" title="Delete symbol" border="0" /></a>
                        </td>
					</tr>
    }
			</tbody>
		</table>
    }
 else
 {
		<p>No records found.</p>
 }
</div>

<script type="text/javascript">
    $(document).ready(function () {
        $(".remove_symbol_lnk").click(function () {
            if (confirm('Are you sure you want to delete this symbol?')) {
                debugger;
                $.ajax({
                    url: '@Url.Action("DeleteSymbol", "Profile")',
                    data: { portfolioId: $(this).attr('data-id'), symbol: $(this).attr('data-text') },
                    type: "POST",
                    cache: false,
                    success: function (result) {
                        LoadUserPortfolios();
                    }
                });
            }

            return false;
        });
        
    });

</script>
